<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
        <title>我的收藏-品购网</title>
        <link href="__PUBLIC__/css/hangye.css" rel="stylesheet" type="text/css" />
        <link href="__PUBLIC__/css/comm.css" rel="stylesheet" type="text/css" />
        <link href="__PUBLIC__/css/panel.css" rel="stylesheet" type="text/css" />
        <link href="__PUBLIC__/css/person.css" rel="stylesheet" type="text/css" />
        <link href="__PUBLIC__/js/auto/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="__PUBLIC__/js/jquery.js"></script>
        <script type="text/javascript" src="__PUBLIC__/js/tree.js"></script>
        <script type="text/javascript" src="__PUBLIC__/js/personquestionshare.js"></script>        
        <script type="text/javascript" src="__PUBLIC__/js/auto/jquery.autocomplete.js"></script>
    </head>
    <body>
	   <div class="containner">
        <include file="Index:header"/>
        <!--导航结束--> 
        <div id="myshare" style="position:absolute;top:0px;margin:auto;z-index:299"></div>
        <div class="body-center">
<!--            <div class="path">
		首页 >> 个人页面 >> 我的收藏
            </div>-->
            <div class="w_tithead"> <strong>您当前的位置是： </strong><a href="__APP__">品购网首页</a><a  href="#">个人信息</a>我的收藏</div>
            <div class="person_title">我的收藏</div>
            <div class="contents">
                <div class="menu">
                    <include file="User:user_menu"/>
                </div>
                <div class="content">
                    <div class="personcainafenxiang_title">我采纳的帖子</div>
                    <div class="searchpanel">
                        <h4>品牌列表：</h4>
                        <div class="brandList" id="brandList">
                            <volist name="basebrand_info" id="brand">
                                <a>{$brand.name}</a>
                            </volist>                            
                        </div>
                        <div class="searchInput">
                            <input type="text"  size="15"   value="请在左侧列表中选择品牌" style="width:120px;"  readonly id="brand_input" onclick="autoContent('__APP__/Home/Share/autoBrand/','brand_input');" >
                            
                            <div class="btns">
                                <a id="search" href="#" hidefocus class="bluebtn caina" stye="text-decoration:none">搜索</a>
                            </div>
                        </div>
                        <div id="fenxiangtiezi" class="fenxiangtiezi">
                            <table class="tablehead">
                                <thead>
                                    <tr>
                                        <td width="15%">品名</td>
                                        <td width="42%">标题</td>
                                        <td width="15%">分享者</td>
                                        <td width="15%">时间</td>
                                        <td width="8%"></td>
                                    </tr>
                                </thead>
                            </table>
                            <div style="height:200px;overflow-y:auto;overflow-x:hidden;">
                                <table id="table">
                                    <tbody>
                                    <volist name="share_info" id="share">
                                        <tr id="{$share.id}">
                                            <td style="color:gray" width="15%"><a href="javascript:;" title="{$share.category.name}-{$share.commodity.name}">{$share.commodity.name}</a></td>
                                            <td width="42%" style="color:#198dc9"><a href="__APP__/Share/show/id/{$share.id}">{$share.caption|html_entity_decode=###}</a></td>
                                            <td style="color:gray" width="15%">{$share.user.user_name}</td>
                                            <td style="color:gray" width="15%">{$share.time_add|date="Y-m-d",###}</td>
                                            <td width="8%" style="color:red;cursor:pointer" method="del">删除</td>
                                        </tr>                                        
                                    </volist>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="personpinfenshagnpin_title">我评分的商品</div>
                        <div id="uppinfenshangpin" class="uppinfenshangpin">
                            <ul style="float:left;">
                                <volist name="history_list" id="history" offset="0" length='8'>
                                    <li class="item">
                                        <ul>
                                            <li class="liindex">
                                                <div class="index one"></div>
                                                <span class="lispan">{$history.commodity.name}</span>
                                                <!--   <span class="detail">详情>></span>-->
                                            </li>
                                            <li class="limessage">
                                                品牌：<span>{$history.brand.name}</span>品类：<span>{$history.commodity.category_id|getAssignInfo='BaseCategory','name'}</span>我的评分：<span class="red end">{$history.commodity_score}↑</span>
                                            </li>

                                        </ul>
                                    </li>
                                </volist>
                            </ul>
                            <ul style="float:right;">
                                <volist name="history_list_asc" id="history" offset="0" length='8'>
                                    <li class="item">
                                        <ul>
                                            <li class="liindex">
                                                <div class="index one"></div>
                                                <span class="lispan">{$history.commodity.name}</span>
                                                <!--   <span class="detail">详情>></span>-->
                                            </li>
                                            <li class="limessage">
                                                品牌：<span>{$history.brand.name}</span>品类：<span>{$history.commodity.category_id|getAssignInfo='BaseCategory','name'}</span>我的评分：<span class="green end">{$history.commodity_score}↓</span>
                                            </li>

                                        </ul>
                                    </li>
                                </volist>
                            </ul>       
                        </div>
                    </div>
                </div>
            </div>
        </div>
	<include file="Index:bottom" />
    <!--页尾部分-->	
	</div>
    </body>
</html>
<script>
    function autoContent(url,obj){
        if($("#"+obj).val() == '请在左侧列表中选择品牌' ){
            $("#"+obj).val('');
        }
        
        bValue = null;
        cValue = null;
        if(obj=='category_input'){
            bValue = $("#brand_input").val();
        }
        else if(obj=='commodity_input'){
            cValue = $("#category_input").val();
            bValue = $("#brand_input").val();
        }
        $("#"+obj).autocomplete(url, {
            width: 230,
            max:10,
            dataType: "json",
            autoFill :false,
            minChars:0,
            selectFirst:false,
            extraParams: {b:bValue,c:cValue},
            scrollHeight: 300,
            parse: function(data) {
                //alert(data);
                if(data.length >=1){
                    return $.map(eval(data), function(row) {
                        res = row.split('-');
                        return {
                            data: row,
                            value: res[1] ,
                            result: res[1]
                        }
                    });
                }
            },
            formatItem: function(item) {
                if(item.length > 1){
                    item = item.split('-');
                    return "<table width='90%'><tr><td align = \"left\">" + item[0] +"</td>"+"<td align = \"right\">"+ item[1]+"</td></tr></table>";
                }
            }
        });
    }

    function bindSearch(){
        $("#search").click(function(){

            var brand = $("#brand_input").val();
            var category = $("#category_input").val();
            var commodity = $("#commodity_input").val();

            if( brand == '请在左侧列表中选择品牌' ){
                alert('请先选择品牌');
                return;
            }
//            if( category == '品类' ){
//                alert('请先选择品类');
//                return;
//            
//            }
//            if(commodity == '品名'){
//                alert('请先选择品名');
//                return;
//            }

            $.post(
            "__APP__/Home/User/searchFavorites",
            {brand_word:brand,category_word:category,commodity_word:commodity},
            function(data){
                $("#fenxiangtiezi").html(data);
                binddel();
            }
        );
        });
    }

    function binddel(){
        $("#table td:[method='del']").click(function(){
            var $td = $(this);
            var $tr = $td.parent();
            var share_id = $tr.attr('id');
            $.get("__APP__/User/delFavorite/",
            {id:share_id},
            function(data){
                if(data==1){
                    alert("删除成功！");
                    var $parent = $tr.parent();
                    $td.unbind();
                    $parent.get(0).removeChild($tr.get(0));
                }
                else{
                    alert("删除失败！");
                }
            });
        });
    }
</script>

